// interface IPolicy {
//   type: number; //类型标识，0-json,1-mongo,2-function
//   effect: 'can' | 'cannot'; // 判断逻辑字段
//   action: string; //操作标识, CURD
//   subject: string; //资源标识, Class类
//   fields?: string[] | string; //字段
//   conditions?: string | Record<string, any>; //查询条件
//   args?: string[] | string; // 针对于函数场景的参数
// }

import { IsIn, IsInt, IsOptional, IsString } from 'class-validator';

type FieldType = string | string[] | Record<string, any>;
export class CreatePolicyDto {
  @IsInt()
  @IsOptional()
  id?: number;

  @IsInt()
  type: number;

  @IsString()
  @IsIn(['can', 'cannot'])
  effect: 'can' | 'cannot';

  @IsString()
  action: string;

  @IsString()
  subject: string;

  @IsOptional()
  fields?: FieldType;

  @IsOptional()
  conditions?: FieldType;

  @IsOptional()
  args?: FieldType;
}
